<template>


    <kv>
      <template #k>
        <div class="k">k8s-api-server
          <remark>
            https://xxx:6443 (可以使用内网IP)
            <br/>
            <br/>
            <div>本地运行，必须设置为： https://k8s-master01:6443</div>
            <div>并配置 /etc/hosts</div>
            <div>k8s-ip k8s-master01</div>
          </remark>
        </div>
      </template>
      <el-input v-model="$model.apiServerHost" chk="*"/>
    </kv>
    <kv>
      <template #k>
        <div class="k">api-token
          <remark>
            <div>参考kuboard</div>
            <pre v-pre>
cat << EOF > kuboard-create-token.yaml
---
apiVersion: v1
kind: Namespace
metadata:
  name: kuboard

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: kuboard-admin
  namespace: kuboard

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kuboard-admin-crb
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: kuboard-admin
  namespace: kuboard

---
apiVersion: v1
kind: Secret
type: kubernetes.io/service-account-token
metadata:
  annotations:
    kubernetes.io/service-account.name: kuboard-admin
  name: kuboard-admin-token
  namespace: kuboard
EOF

kubectl apply -f kuboard-create-token.yaml
echo -e "\033[1;34m将下面这一行红色输出结果填入到 kuboard 界面的 Token 字段：\033[0m"
echo -e "\033[31m$(kubectl -n kuboard get secret \
    $(kubectl -n kuboard get secret kuboard-admin-token |\
    grep kuboard-admin-token | \
    awk '{print $1}') \
    -o go-template='{{.data.token}}' | base64 -d)\033[0m"

          </pre>
          </remark>
        </div>
      </template>
      <el-input v-model="$model.apiToken" type="textarea" :autosize="{ minRows: 3, maxRows: 6 }"/>
    </kv>

    <kv label="启用挂载configmap">
      <template #k>
        <div class="k">挂载 configmap
          <remark>
            <div>1. 挂载内容：挂载同名称空间下，名称为 {spring.application.name} 的 configmap
            </div>
            <div>2. 挂载目标：jar 文件同级的 config 文件夹下</div>
            <div>3. config文件夹下的 application.yml 优化级最高</div>
          </remark>
        </div>
      </template>
      <el-switch
          v-model="$model.mountConfigmap">
      </el-switch>
    </kv>
    <kv label="启用Istio">
      <el-switch
          v-model="$model.enableIstio">
      </el-switch>
    </kv>

</template>

<script setup>
/**
 * Created by CodeGenerator  at 2022-04-29 17:00:15
 */


defineOptions({
  name: "k8s-config",
  inheritAttrs: true,
});

//定义 vue2的this,当前组件
const $self = getCurrentInstance();

//定义 $attrs
const $attrs = useAttrs();

const $props = defineProps({
  id: {type: String},
  action: {type: String},
  title: {type: String}
});


const $model = defineModel({type: Object});


const list = ref();

//定义事件
const $emit = defineEmits(["update:modelValue", "loaded"]);


</script>
